<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>JFinal Controller 响应请求response</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">   
	<link rel="stylesheet" href="assets/css/bootstrap.min.css">
	<link rel="stylesheet" href="assets/css/bootstrap-theme.min.css">
	<!-- 本案例自定义css样式表 -->
	<link rel="stylesheet" href="assets/css/xmxt.css">
	<script src="assets/js/jquery.js"></script>
	<script src="assets/js/bootstrap.min.js"></script>
	<!-- renderjavascript 演示 -->
	<script type="text/javascript" src="/render/renderjs"></script>
	<style type="text/css">
	 a{
		display: block;
	}
	 a:hover{
		color:red;
	}
	a:active{
		color:blue;
	}
	fieldset{
		display: none;
		width:880px;
		padding: 20px;
	}
	fieldset a{
	display:block;
		margin-bottom: 5px;
	}
	</style> 
	<script type="text/javascript">
	function activeIt(index){
		var lis = document.getElementsByTagName("li");
		for(var i=0;i<lis.length;i++){
			if(index==i){
				lis[i].style.color="red";
				lis[i].childNodes.item(0).style.color="red";
			}else{
				lis[i].style.color="#666FFF";
				lis[i].childNodes.item(0).style.color="#666FFF";
			}
		}
	}
		function showIt(index){
			activeIt(index);
			var fieldsets = document.getElementsByTagName("fieldset");
			for(var i=0;i<fieldsets.length;i++){
				if(index==i){
					fieldsets[i].style.display="block";
				}else{
					fieldsets[i].style.display="none";
				}
			}
		}
	</script>
  </head>
  
  <body>
 <div class="header">
  <div class="container">
    <div class="row">
      <div class="col-xs-12">
      <div class="logotxt shadowfont"><h1>JFinal极速开发实战教程</h1></div> 
      <h2 class="text-center shadowfont">小木学堂</h2>
    </div>
  </div>
</div>
</div>
  <div class="container" style="background: #FFF;height: 650px;">
  <div class="page-header">
  <h1>JFinal Controller 响应请求response</h1>
  </div>
  <div class="row mainRow">
  <div class="col-lg-6 col-md-6 col-sm-6">
  <ol id="titles">
  <li><a href="javascript:showIt(0)">普通请求jsp</a></li>
  <li><a href="javascript:showIt(1)">重定向jsp</a></li>
  <li><a href="javascript:showIt(2)">返回固定格式 renderText</a></li>
  <li><a href="javascript:showIt(3)">返回固定格式 renderXml</a></li>
  <li><a href="javascript:showIt(4)">返回固定格式 renderHtml</a></li>
  <li><a href="javascript:showIt(5)">返回固定格式 renderJavascript</a></li>
  <li><a href="javascript:showIt(6)">文件下载 renderFile</a></li>
  </ol>
  <fieldset >
  	<legend>一、普通请求jsp页面  主要使用render(view) renderJsp(view)等</legend>
  	<ol>
  	<li><a href="/render/render" target="_blank">访问jsp页面-render("renderjsp.jsp")</a></li>
  	<li><a href="/render/renderjsp" target="_blank">访问jsp页面-renderJsp("renderjsp.jsp")</a></li>
  	<li><a href="/render/renderjsp" target="_blank">访问jsp页面 传值-renderJsp("renderjsp.jsp") 传值使用setAttr("renderMethod", "renderjsp")</a></li>
  	</ol>
  </fieldset>
  <fieldset>
  	<legend>二、重定向jsp页面 外网地址 主要使用redirect(url)</legend>
  	<ol>
  	<li><a href="/render/redirectwrong" target="_blank">访问jsp页面 错误用法-redirect("renderjsp.jsp")</a></li>
  	<li><a href="/render/redirecturl" target="_blank">跳转外网地址-redirect("http://www.baidu.com")</a></li>
  	<li><a href="/render/redirectothercontroller" target="_blank">跳转到其它Controller-redirect("/param")</a></li>
  	<li><a href="/render/redirectminecontroller" target="_blank">跳转到自身Controller-redirect("testredirect")</a></li>
  	<li><a href="/render/redirectwithparam" target="_blank">带参数跳转到自身Controller-redirect("testredirect?param=1")</a></li>
  	<li><a href="/render/redirectnexturlwithparam?param1=1" target="_blank">带参数跳转到ParamController[/render/redirectnexturlwithparam?param1=1]-redirect("/param/urlmoreparam?param2=2")</a></li>
  	</ol>
  </fieldset>
   <fieldset>
  	<legend>三、返回固定格式数据 renderText(text)  renderText(text,contentType)</legend>
  	<ol>
  	<li><a href="/render/rendertext" target="_blank">返回text类型数据 renderText(text)</a></li>
  	<li><a href="/render/rendertext1" target="_blank">返回text类型数据 renderText(text,ContentType.TEXT)</a></li>
  	<li><a href="/render/rendertext2" target="_blank">返回HTML类型数据 renderText(text,ContentType.HTML)</a></li>
  	<li><a href="/render/rendertext3" target="_blank">错误用法：返回XML类型数据 renderText(text,ContentType.XML)</a></li>
  	<li><a href="/render/rendertext4" target="_blank">正确用法：返回XML类型数据 renderText(text,ContentType.XML)</a></li>
  	</ol>
  </fieldset>
   <fieldset>
  	<legend>四、返回固定格式数据 renderXml(blog.xml)</legend>
  	<a href="/render/renderxml" target="_blank">返回XML类型数据 renderXml("blog.xml")</a><br>
  	</fieldset>
   <fieldset>
  	<legend>五、返回固定格式数据 renderHtml(htmltext)</legend>
  	<a href="/render/renderhtml" target="_blank">返回HTML类型数据 renderHtml(htmltext)</a><br>
  	</fieldset>
   <fieldset>
  	<legend>六、返回固定格式数据 renderJavascript(js)</legend>
  	<button onclick="renderjs()">点击执行</button>
  	</fieldset>
   <fieldset>
  	<legend>七、文件下载 renderFile("filepath")</legend>
  	<ol>
  	<li><a href="/render/renderfileuespath">下载文件 使用路径 renderFile(filepath)</a></li>
  	<li><a href="/render/renderfileusefile">下载文件 使用文件对象 renderFile(File)</a></li>
  	</ol>
  	</fieldset>
  </div>
  <jsp:include page="../qrcode.jsp"></jsp:include>
  </div>
  </div>
  <jsp:include page="../footer.jsp"></jsp:include>
